package com.ruoyi.iot.config;

//import io.renren.modules.farm.entity.FacTaskjobEntity;
//import io.renren.modules.farm.task.BaseTaskService;
//import jakarta.annotation.Resource;
import com.ruoyi.iot.domain.FacTaskjob;
import com.ruoyi.iot.service.task.BaseTaskService;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class ScheduledTaskRunner implements ApplicationRunner {

    @Autowired
    private BaseTaskService scheduledTaskService;
    /**
     * 程序启动完毕后,需要自启的任务
     */
    @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {
        log.info(" >>>>>> 项目启动完毕, 开启 => 需要自启的任务 开始!");
        List<FacTaskjob> scheduledTaskBeanList = scheduledTaskService.getAllNeedStartTask();
        scheduledTaskService.initAllTask(scheduledTaskBeanList);
        log.info(" >>>>>> 项目启动完毕, 开启 => 需要自启的任务 结束！");
    }
}
